// [2016]增量元素之间的最大差值
struct Solution;

//leetcode submit region begin(Prohibit modification and deletion)
impl Solution {
    pub fn maximum_difference(nums: Vec<i32>) -> i32 {
        let mut result = -1;
        for i in 0..nums.len() {
            for j in (i+1)..nums.len() {
                if nums[j] > nums[i] {
                    result = result.max(nums[j] - nums[i]);
                }
            }
        }
        result
    }
}
//leetcode submit region end(Prohibit modification and deletion)


#[test]
fn main() {
    let nums = vec![7,1,5,4];
    assert_eq!(Solution::maximum_difference(nums), 4);
    let nums = vec![9,4,3,2];
    assert_eq!(Solution::maximum_difference(nums), -1);
    let nums = vec![1,5,2,10];
    assert_eq!(Solution::maximum_difference(nums), 9);
}